GenerativeComponents Help

ExcelRange.WriteValue

Writing information to an Excel® spreadsheet is similar to reading data. First save a spreadsheet that you can access from GenerativeComponents. In this example use the same spreadsheet from which we read data earlier.

In the ExcelRange.WriteValue input properties, input the file path for the spreadsheet in the WorkbookFileName field and specify a sheet in the SheetName property. Assign a cell or range of cells as a string in the RangeAddress field, in this case A6.

The value to be written to an Excel spreadsheet can vary widely; nearly all data types are valid, including combinations of different data types. In this example, you simply export the length of the curve drawn through the points that were based on the spreadsheet's coordinate values. However, rather than simply report the length of the curve, we would also like to annotate what the value is referring to. The first value to export is a string, followed by the length property of the node "bsplineCurve02." In order for GenerativeComponents to understand that it needs to export multiple values, each value must be concatenated, or separated by the plus (+) symbol. This is the C# and GCScript convention for joining two strings, though it will work with more than just string values. For more information on GCScript, refer to GCScript Programming.

The string portion of the input property is "Curve Length = ". Use the plus (+) symbol to indicate more values will be exported. The second value is the length of the B-spline curve. This value is accessed by using the dot operator (.): bsplineCurve01.Length. At this point you can click Write but the output will be accurate to 13 decimal places. To shorten the decimal, use the Round() function, specifying that GenerativeComponents should round the value to a less precise number. The input should look like the following:

Value = "Curve Length = " + Round(bsplineCurve01.Length,
3)

Clicking Write exports the value to Excel. The current length of the curve is 17.153.

The new link to Excel is dynamic and will change every time the associated value changes. For instance, the ExcelRange.WriteValue could be linked to the length of a curve defined by points made in GenerativeComponents. In this case, every time a point is moved and the length of the curve changes dynamically, so will the value in Excel.